<?php
namespace app\controller;

use app\facade\Token;
use app\model\chat\ChatModel;

class Chat
{
    public function post() {
        $uid = Token::getUid();
        $msg = input("post.msg");

        $chat = new ChatModel();

        $chat->uid = $uid;
        $chat->msg = $msg;
        $chat->save();

        return json(["msg"=>""]);
    }

    public function get() {
        return json(ChatModel::order('id', 'desc')->limit(10)->select());
    }
}